//
//  HWLiveAssetsCell.swift
//  HWanGame
//
//  Created by 王昌健 on 2022/1/19.
//  Copyright © 2022 94Wan. All rights reserved.
//

import UIKit

class HWLiveAssetsCell: UITableViewCell {

    var bgView:UIView!
    var iconView:UIImageView!
    var titleLabel:UILabel!
    var priceLabel:UILabel!
    var arrowImageView:UIImageView!
    
    class func cellWithTableView(tableView:UITableView) -> (HWLiveAssetsCell) {
        let reUse:String = "HWLiveAssetsCell"
        
        var cell = tableView.dequeueReusableCell(withIdentifier: reUse)
        
        if cell == nil {
            cell = HWLiveAssetsCell.init(style: UITableViewCell.CellStyle.default, reuseIdentifier: reUse)
        }
        
        return cell as! HWLiveAssetsCell
    }
    
    
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        
        initUI()
        initFrame()
    }
    
    func initUI() -> Void {
        selectionStyle = UITableViewCell.SelectionStyle.none
        backgroundColor = UIColor.clear
        
        bgView = UIView()
        bgView.backgroundColor = .white
        bgView.layer.cornerRadius = 8*widthScale
        contentView.addSubview(bgView)
        
        iconView = UIImageView()
        bgView.addSubview(iconView)
        
        titleLabel = HWLabel.createBoldLabel(title: "", color: "#444444", font: 16*widthScale)
        bgView.addSubview(titleLabel)
        
        priceLabel = HWLabel.createBoldLabel(title: "", color: "#444444", font: 14*widthScale)
        bgView.addSubview(priceLabel)
        
        arrowImageView = UIImageView()
        arrowImageView.image = UIImage(named: "ba_r")
        bgView.addSubview(arrowImageView)
    }
    
    func initFrame() -> Void {
        bgView.snp.makeConstraints { make in
            make.left.equalTo(20*widthScale)
            make.right.equalTo(-20*widthScale)
            make.top.equalTo(5*widthScale)
            make.bottom.equalTo(-5*widthScale)
            make.height.equalTo(54*widthScale)
        }
        
        iconView.snp.makeConstraints { make in
            make.left.equalTo(15*widthScale)
            make.centerY.equalToSuperview()
            make.width.height.equalTo(16*widthScale)
        }
        
        titleLabel.snp.makeConstraints { make in
            make.left.equalTo(iconView.snp.right).offset(6*widthScale)
            make.centerY.equalToSuperview()
        }
        
        arrowImageView.snp.makeConstraints { make in
            make.right.equalTo(-14*widthScale)
            make.centerY.equalToSuperview()
            make.width.equalTo(9*widthScale)
            make.height.equalTo(14*widthScale)
        }
        
        priceLabel.snp.makeConstraints { make in
            make.centerY.equalToSuperview()
            make.right.equalTo(arrowImageView.snp.left).offset(-8*widthScale)
        }
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }

}
